package com.weiyi.mashangzhu.Roomer.Activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;
import com.weiyi.mashangzhu.Base.BaseActivity;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Utils.UiUtil;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GuideActivity extends BaseActivity {
public static GuideActivity guideActivity;
    @BindView(R.id.second)
    TextView second;
    int second_num;
    Handler handler=new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            if (msg.what==0x001){
                if (second_num>=2){
                    second_num-=1;
                    second.setText(second_num+"");
                    handler.sendEmptyMessageDelayed(0x001, 1000);
                }else if (second_num==1){
                    UiUtil.startActivity(GuideActivity.this,MainActivity_R.class);
                }

            }
            return false;
        }
    });

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        ButterKnife.bind(this);
        guideActivity=this;
        second_num=Integer.parseInt((second.getText()+"").trim());
        handler.sendEmptyMessageDelayed(0x001, 1000);

    }

    @OnClick(R.id.skip)
    public void onViewClicked() {
        second_num=-1;
        UiUtil.startActivity(GuideActivity.this,MainActivity_R.class);
    }
}
